package com.situ.day2;

import org.junit.Test;

import java.util.Scanner;

public class SwitchDemo {

    @Test
    public void test1() {
        int num = 1;
        switch (num) {
            case 1:
                System.out.println("1");
                break;
            case 2:
                System.out.println("2");
                break;
            case 3:
                System.out.println("3");
                break;
            default:
                System.out.println("default");
                break;
        }
    }

    //    输入月份判断天数：
//    1、3、5、7、8、10、12  -------- 31天
//    4、6 、9、11--------------------30天
//    2----------------------------------28/29天
    @Test
    public void test2() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
                System.out.println("31天");
                break;
            case 2:
                System.out.println("28/29天");
                break;
            case 3:
                //Duplicate branch in 'switch'
                System.out.println("31天");
                break;
            case 4:
                System.out.println("30天");
                break;
            case 5:
                System.out.println("31天");
                break;
            case 6:
                System.out.println("30天");
                break;
            case 7:
                System.out.println("31天");
                break;
        }
    }

    @Test
    public void test21() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                System.out.println("28/29天");

                break;
        }
    }


}
